import {type ISelectProps} from "element-plus";

export  enum FormItemType{
    INPUT_TEXT = 'input_text',
    INPUT_NUMBER = 'input_number',
    INPUT_PASSWORD = 'input_password',
    INPUT_SEARCH = 'input_search',
    TEXTAREA = 'input_textarea',
    INPUT_HIDDEN = 'input_hidden',
    SELECT = 'select', //值为数组
    CUSTOMIZE_SELECT = 'customizeSelect', //值为数组
    SEARCH_SELECT = 'searchSelect',
    DIC_SELECT = 'dicSelect',
    CHECKBOX = 'checkbox',
    FILE = 'file',
    RADIO = 'radio',
    PICKER = 'picker',
    SLOT = 'slot'
}

export interface BaeFormComponentItem{
    inputSize?: 'large' | 'small' | 'default';
    inputWidth?:string;
    placeholder?: string;
    defaultValue?:string | Array<{[key: string] : any}> | number | Array<string>;
}

export interface ICustomizeSelect extends BaeFormComponentItem{
    name?:string,
    textFiled?: string,
    valueField?: string,
    selectedChange?: (value:any) => void;
    url?:string;
    isMultiple?: boolean;
    property?: {
        [key: string] : any
    }
}

export interface FormViewItem extends BaeFormComponentItem{
    label: string,
    type: FormItemType;
    name: string;
    options?:[] //select radio checkbox
    isMultiple?: boolean;//searchInput
    colSpan?: 1 | number;
    dicType?: string; // dicSelect 自定义下拉组件
    property?: {
        [key:string]:any;
    },
}

export interface FormView {
    splitCol?: number ; //分割表单为4列
    gutter?: number;
    hasShow?:boolean;
    width?:string;
    showSubmit?:boolean;
    showReset?:boolean;
    rules?: {};
    inputSize?: 'large' | 'small' | 'default'
    labelWidth?:number;
    dataChange?:(oldValue:object,newValue:object,field:string) => void
    items: FormViewItem[];
}

export interface DialogFormInterface {
    title?: string
    width?: string;
    form:FormView;
    beforeClose?:() => boolean;
    dataChange?:(oldValue:object,newValue:object,field:string) => void
}

export interface ICustomizeSelectProps extends ISelectProps{
    textFiled?: string,
    valueField?: string,
    selectedChange?: (value:any) => void;
    defaultValue?:string | [] | number;
    url?:string;
}


